package pcserver;

import javax.swing.*;
import java.net.URL;
import java.applet.*;

public class BackMusic extends JApplet {
	private static final long serialVersionUID = 1L;
	
	private AudioClip audioClip;
	private boolean isPlay;

	public BackMusic() {
		isPlay = false;
	}
	
	public void setMusic(String name){
		URL urlForAudio = getClass().getResource(name);
		audioClip = Applet.newAudioClip(urlForAudio);
	}

	public void loop() {
		if(audioClip != null){
			isPlay = true;
			audioClip.loop();	
		}
	}
	
	public void play() {
		if (audioClip != null) {
			isPlay = true;
			audioClip.play();
		}
	}

	public void stop() {
		if (audioClip != null) {
			isPlay = false;
			audioClip.stop();
		}
	}

	public boolean isPlay() {
		return isPlay;
	}

}
